<script setup>
import { onMounted, onBeforeUnmount } from 'vue';
import { WorkspaceService } from './services/WorkspaceService';
import { initTheme } from './assets/theme.js';
// import { initHotkeys } from './assets/hotkeys.js';
import { setupLocalHistory } from './assets/local-history.ts';
import AppShell from './layouts/AppShell.vue';

onMounted(() => { initTheme(); /* initHotkeys(); */ setupLocalHistory(); });

// 添加清理逻辑
onBeforeUnmount(async () => {
  try { await WorkspaceService.stop(); } catch {}
});

// 监听浏览器关闭事件
if (typeof window !== 'undefined') {
  window.addEventListener('beforeunload', async (e) => {
    try { await WorkspaceService.stop(); } catch {}
  });
}
</script>

<template>
  <AppShell>
    <template #workspace>
      <router-view />
    </template>
  </AppShell>
</template>

<style>
html, body, #app { height: 100%; margin: 0; overflow: hidden; }
</style>
